package com.pounds.control;

import com.pounds.pojo.Charge;
import com.pounds.service.ChargeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("peaceful/charge")
public class ChargeControl {

    @Autowired
    private ChargeService chargeService;

    @GetMapping("select")
    public List<Charge> getChargeList() {
        return chargeService.getChargeList();
    }

    @GetMapping("new")
    public String addCharge(int user, String enter, String come, String price, String need, String note) {
        return chargeService.addCharge(user, enter, come, price, need, note);
    }

    @GetMapping("delete")
    public String deleteCharge(int id) {
        return chargeService.deleteCharge(id);
    }

    @GetMapping("update")
    public String updateCharge(int id, int user, String enter, String come, String price, String need, String note) {
        return chargeService.updateCharge(id, user, enter, come, price, need, note);
    }
}
